Specifying a useless option doesn't result in an error.
Notes
• clip2gif is recordable (i.e. you can record the conversions with all their options in an AppleScript by pushing the record button of the ScriptEditor).
• "clipboard" can be used as the object of "save", "drawn picture", "get", "set" and "measure" (note that "get" is often implicit in AppleScript: you can write "set cl to clipboard").
• "screen" can be used as the object of "save", "drawn picture" and "get".
• Due to a limitation of the Mac toolbox, clip2gif must be active in order to use the clipboard (as well as any application you copy a PICT from); use "activate" in scripts.
• If one specifies "in string" for the save output, the result corresponds to the file content for GIFs, TIFFs and JPEGs, but not for PICTs. PICTs in strings correspond to the content of a picture in memory (PicHandle or clipboard or AppleEvent data). PICT files have an additional header of 512 bytes.
• If one specifies "in picture" for the save output, the result is a PICT that can be used as input for other conversions, or as the parameter of "drawn picture" (see below). "in picture" overrides "as ...".
• If one specifies "in window" for the save output, a new window is opened.
• Cropping a PICT does not remove what is clipped out. The PICT size will not decrease. Only the bounding rectangle is changed.
• With System 7 to 7.1, AppleEvent objects are limited to 64 kilobytes. Consequently, with these systems, "in string" and "in picture" cannot be used with large images. With images larger than a few kilobytes, one cannot run AppleScripts from Script Editor, unless Script Editor memory partition has been increased in the Finder (Get Info). One has to create applets and increase their default memory partition.
Typical use
tell application "clip2gif"
save file "foo.pict" as GIF scale 50 depth 4 with interlacing transparency first pixel
--creates a file named test.gif based on foo.pict
end tell
Drawings
It's possible to script clip2gif to draw simple graphical elements, such as text, lines, frames and filled rectangles. For this, use the drawing argument. Scale has no effect. You can start either with an existing picture (specify a PICT or GIF file the usual way), or with a blank rectangle (specify its size as a list of two numbers). The argument of drawing is a list of records containing:
drawn text plain text -- the text to draw
rectangle a list of small integer -- filled rectangle
frame a list of small integer -- rectangle outline
disk a list of small integer -- disk or filled ellipse described by its bounding rect.
circle a list of small integer -- circle or ellipse described by its bounding rect.
line a list of small integer -- connected straight line(s)
polygon a list of small integer -- filled polygon
drawn picture picture -- PICT clipped to its bounding rectangle
chart data a list of small integer -- chart data values (in pixels or degrees)
color RGB color -- red, green and blue (0-65535)
thickness small integer -- line thickness
position a list of small integer -- position ({x, y} or {left, top, right, bottom})
justification right/left/centered -- text justification
font plain text -- font name
size small integer -- characters size (in points)
style a list of bold/italic/outline/shadow/underline/condensed/expanded -- the styles for the text
chart style bars/lines/pie
Each chart data value can be followed by an RGB color (list of three small integers). This is especially useful for pie charts, as shown below.
Examples
--converts a PICT file to GIF and adds a title
save file "test.pict" as GIF with interlacing drawing
{{drawn text:"This is a test", position:{50,20}, color:{65535,0,0},font:"Times",size:24,style:{bold}}}
--creates a drawing from scratch in a new window with a line, a frame, a filled rectangle and centered text
--gets the content of a folder as the image of its Finder window
set fdr to choose folder
tell application "Finder"
activate
open fdr
set r to bounds of window 1
end tell
tell application "clip2gif" to save screen crop r in window
tell application "Finder" to close window 1
--animates two discs
tell application "clip2gif"
save {150, 100} in window --new blank window
repeat with i from 10 to 70 by 5
save {150, 100} drawing {{disk:{i, i, i + 20, i + 20}, color:{65535, 0, 0}},
{disk:{100 - i, 80 - i, 120 - i, 100 - i}, color:{0, 0, 65535}}} in window 1
end repeat
end tell
For another example, open a new window in the Script Editor, click on the recording button, switch to clip2gif, select "About clip2gif..." in the Apple menu. Then switch back to the Script Editor and click on the Stop button.
For more information about scripting...
If you have installed AppleGuide (standard with MacOS 7.5 and later, optional with MacOS 7.1), open the Help menu (? icon at the right of the menu bar) and choose clip2gif Guide. There are detailed information about scripting, and many examples.
For documentation about how to use clip2gif with other applications, look in the Scripting clip2gif folder.
Using clip2gif from another program
Several functions of clip2gif 0.7.1 and later can be used from other programs compiled for the PowerPC with the Code Fragment Manager. See the header file LoadClip2Gif.h and the examples for more details.
Note that you may not include clip2gif with your programs without a prior agreement. Cf. the Copyright notice in the main ReadMe file. LoadClip2Gif.h and LoadClip2Gif.c, however, can be used freely.
Small Print
This document is Copyright 1995, Yves Piguet. All rights reserved.
The author makes no warranty with respect to this document, its quality, accuracy, or fitness for a particular purpose. As a result, this document is provided "as is", and the user is assuming the entire risk as to its quality and accuracy.